package com.tansun.easycare.rule.modelauthority.service.impl;

import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import com.tansun.easycare.rule.common.model.BaseModel;
import com.tansun.easycare.rule.common.service.impl.RuleBaseServiceImpl;
import com.tansun.easycare.rule.modelauthority.dao.RuleModelAuthorityDao;
import com.tansun.easycare.rule.modelauthority.entity.RuleModelAuthority;
import com.tansun.easycare.rule.modelauthority.service.RuleModelAuthorityService;

@Service
public class RuleModelAuthorityServiceImpl extends RuleBaseServiceImpl<RuleModelAuthorityDao, RuleModelAuthority> implements RuleModelAuthorityService {

    @Override
    public RuleModelAuthority saveOrUpdate(BaseModel index, String manageId) {
        RuleModelAuthority ruleModelAuthority = null;
        if (StringUtils.isEmpty(index.getId())) {
            ruleModelAuthority = new RuleModelAuthority();
            ruleModelAuthority.setUsers(index.getUsers());
            ruleModelAuthority.setOwner(index.getOwner());
            ruleModelAuthority.setProjectCode(index.getProjectCode());
            ruleModelAuthority.setManageId(manageId);
        }
        if (ruleModelAuthority != null)
            this.save(ruleModelAuthority);
        return ruleModelAuthority;
    }


}
